const encodeSearchParams = obj => {
    const params = []
    Object.keys(obj).forEach((key) => {
        let value = obj[key]
        if (typeof value === 'undefined') {
            value = ''
        }
        params.push([key, encodeURIComponent(value)].join('='))
    })
    return params.join('&')
}

const push = ({path, query = {}}) => {
    window.history.pushState(null, null, `${path}?${encodeSearchParams(query)}`)
}
export default {
    push
}